<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <script src="./vendor/avalon/avalon.js" ></script>
        <script>
            var model1 = avalon.define({
                $id: "test1",
                background: "red"
            })
            // model.$watch("background", function(v) {
            //     model.background = v
            // })


            var model2 = avalon.define({
                $id: "test2",
                percent: 0
            })
            var a = true
            var id = setInterval(function() {
                if (a) {
                    if (model2.percent < 100) {
                        model2.percent++
                    } else {
                        a = false
                    }
                } else {
                    if (model2.percent > 0) {
                        model2.percent--
                    } else {
                        a = true
                    }
                }
            }, 100)



            var model3 = avalon.define({
                $id: "test3",
                w: 100,
                h: 100,
                click: function() {
                    model3.w = parseFloat(model3.w) + 10;
                    model3.h = parseFloat(model3.h) + 10;
                }
            })

        </script>
        <style type="text/css">
            .handerx{
                width:20px;
                height:20px;
                position: absolute;
                color:#fff;
                background: #000;
            }
            .sliderx{
                width:100%;
                height:20px;
                position: relative;
            }
            .body{
                padding:40px;
            }
        </style>
    </head>
    <body>
        <div ms-controller="test1">
            <div style="width:200px; height:50px" ms-css-background="background"></div>
            <select ms-duplex="background">
                <option value="red">红</option>
                <option value="yellow">黄</option>
                <option value="green">绿</option>
            </select>
        </div>


        <div ms-controller="test2" class="body">
            <div class="slider" style="background:red;">
                <div class="handerx" ms-css-left="{{percent}}%" >{{percent}}</div>
                <div style="background: greenyellow;height:20px" ms-css-width="{{percent}}%"></div>
            </div>
            <div class="sliderx" style="background:#d2d2d2;">
                <div style="background: #2FECDC;height:20px" ms-css-width="{{100-percent}}%"></div>
            </div>
        </div>


        <div ms-controller="test3">
            <div style=" background: #a9ea00;" ms-css-width="w" ms-css-height="h"  ms-click="click"></div>
            <p>{{ w }} x {{ h }}</p>
            <p>W: <input type="text" ms-duplex="w" data-duplex-event="change"/></p>
            <p>H: <input type="text" ms-duplex="h" /></p>
        </div>

    </body>
</html>